app.controller("uscheduleCtr", ["$scope", "$http", "$filter", "$rootScope", "$stateParams", "$timeout", "lodash",
function($scope, $http, $filter, $rootScope, $stateParams, $timeout, lodash) {
    $scope.info = {
        areaList: config_area_list,
        sltAreaName: lodash.first(config_area_list).areaName,
        programeList: [
            {"key": "SMS", "name": "SMS", "crtname": "SMS"},
            {"key": "OMS", "name": "OMS", "crtname": "OMS"},
            {"key": "UPS", "name": "UPS", "crtname": "UPS"},
            {"key": "SG", "name": "SG", "crtname": "SG"}
        ],
        sltProgrameItem: "",
        apiArray: [
            {"id": 1, "name": "任务-001", "crtname": "任务-001", "path": "com.winit.sms.spi.packingalgorithm.PackingAlgorithmService", "programe": "SMS", "otherValue": "com.winit.sms.spi.packingalgorithm.PackingAlgorithmService"},
            {"id": 2, "name": "任务-002", "crtname": "任务-002", "path": "com.winit.oms.spi.packingalgorithm.PackingAlgorithmService", "programe": "OMS", "otherValue": "com.winit.oms.spi.packingalgorithm.PackingAlgorithmService"},
            {"id": 3, "name": "任务-003", "crtname": "任务-003", "path": "com.winit.ups.spi.packingalgorithm.PackingAlgorithmService", "programe": "UPS", "otherValue": "com.winit.ups.spi.packingalgorithm.PackingAlgorithmService"},
            {"id": 4, "name": "任务-004", "crtname": "任务-004", "path": "com.winit.sg.spi.packingalgorithm.PackingAlgorithmService", "programe": "SG", "otherValue": "com.winit.sg.spi.packingalgorithm.PackingAlgorithmService"},
        ],
        apiList: [],
        sltApiItem: "",
        resultList: []
    };

    // 切换区域
    $scope.switchArea = function(area) {
        console.log(area);
        $scope.info.sltAreaName = area.areaName;
    };

    // 切换工程
    $scope.selectProgrameFun = function(item) {
        $scope.info.showApiLoading = true;
        $scope.info.sltApiItem = "";
        var selectApiList = new Array();
        angular.forEach($scope.info.apiArray, function(apiItem) {
            if(apiItem.programe == item.key) {
                selectApiList.push(apiItem);
            }
        });
        $timeout(function() {
            $scope.info.apiList = selectApiList;
            $scope.info.showApiLoading = false;
        }, 1000);
    };

    // 点击调试按钮
    $scope.clickTestBtn = function() {
        $rootScope.toasterSuccessInfo("调用成功，请等待返回结果！");
        var addItem = {"name": $scope.info.sltApiItem.name, "info": $scope.info.sltApiItem.name+"的结果！！！"};
        $timeout(function() {
            $scope.info.resultList.push(addItem);
        }, 2000);
    }



}]);
